'''
    进制转换，一般采取除法取余数的方法，因为要反转，用栈存储再出栈更为方便
'''
from Stack import Stack
def baseConverter(decNumber,base):
    digits = '0123456789ABCDEF' # 字符数组
    remstack = Stack()  # 创建栈
    while decNumber > 0:
        remstack.push(decNumber % base)
        decNumber = decNumber // base
    result = ''
    while not remstack.isEmpty():
        result = result + digits[remstack.pop()]    # 相当于pop出来的是下标
    return result

if __name__ == '__main__':
    print(baseConverter(28,16))

